package guoanmaker.operator.business.model;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;

import guoanmaker.operator.helper.common.abstractobj.IdEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name="t_operator_role")
public class OperatorRole extends IdEntity implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Column(name="rolename")
	private String rolename;
	@Column(name="rolecode")
	private String rolecode;
	@DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss") 
	@Column(name="create_time")
	private Date createTime;
	@Column(name="create_userid")
	private String createUserid;
	@Column(name="status")
    private int status;
	@Column(name="create_user")
	private String createUser;
	
	@Column(name="pids")
	private String  pids;//权限项
	
	@JsonIgnore
	@ManyToMany(mappedBy = "roles")
	@JSONField(serialize=false)
	private Set<OperatorUser> users;
	
	public String authority() {
	    return "ROLE_" + this.rolecode;
	  }

}
